/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import ts from '~/vendor/ohos-typescript';

import { NodePredicate } from '~/type/Predicate';

/**
 * @category AST Type
 */
export const BreakOrContinueStatement: NodePredicate<ts.BreakOrContinueStatement> = {
    is(node): node is ts.BreakOrContinueStatement {
        return ts.isBreakOrContinueStatement(node);
    },
};

/**
 * @category AST Type
 */
export const VariableStatement: NodePredicate<ts.VariableStatement> = {
    is(node): node is ts.VariableStatement {
        return ts.isVariableStatement(node);
    },
};

/**
 * @category AST Type
 */
export const EmptyStatement: NodePredicate<ts.EmptyStatement> = {
    is(node): node is ts.EmptyStatement {
        return ts.isEmptyStatement(node);
    },
};

/**
 * @category AST Type
 */
export const ExpressionStatement: NodePredicate<ts.ExpressionStatement> = {
    is(node): node is ts.ExpressionStatement {
        return ts.isExpressionStatement(node);
    },
};

/**
 * @category AST Type
 */
export const IfStatement: NodePredicate<ts.IfStatement> = {
    is(node): node is ts.IfStatement {
        return ts.isIfStatement(node);
    },
};

/**
 * @category AST Type
 */
export const DoStatement: NodePredicate<ts.DoStatement> = {
    is(node): node is ts.DoStatement {
        return ts.isDoStatement(node);
    },
};

/**
 * @category AST Type
 */
export const WhileStatement: NodePredicate<ts.WhileStatement> = {
    is(node): node is ts.WhileStatement {
        return ts.isWhileStatement(node);
    },
};

/**
 * @category AST Type
 */
export const ForStatement: NodePredicate<ts.ForStatement> = {
    is(node): node is ts.ForStatement {
        return ts.isForStatement(node);
    },
};

/**
 * @category AST Type
 */
export const ForInStatement: NodePredicate<ts.ForInStatement> = {
    is(node): node is ts.ForInStatement {
        return ts.isForInStatement(node);
    },
};

/**
 * @category AST Type
 */
export const ForOfStatement: NodePredicate<ts.ForOfStatement> = {
    is(node): node is ts.ForOfStatement {
        return ts.isForOfStatement(node);
    },
};

/**
 * @category AST Type
 */
export const ContinueStatement: NodePredicate<ts.ContinueStatement> = {
    is(node): node is ts.ContinueStatement {
        return ts.isContinueStatement(node);
    },
};

/**
 * @category AST Type
 */
export const BreakStatement: NodePredicate<ts.BreakStatement> = {
    is(node): node is ts.BreakStatement {
        return ts.isBreakStatement(node);
    },
};

/**
 * @category AST Type
 */
export const ReturnStatement: NodePredicate<ts.ReturnStatement> = {
    is(node): node is ts.ReturnStatement {
        return ts.isReturnStatement(node);
    },
};

/**
 * @category AST Type
 */
export const WithStatement: NodePredicate<ts.WithStatement> = {
    is(node): node is ts.WithStatement {
        return ts.isWithStatement(node);
    },
};

/**
 * @category AST Type
 */
export const SwitchStatement: NodePredicate<ts.SwitchStatement> = {
    is(node): node is ts.SwitchStatement {
        return ts.isSwitchStatement(node);
    },
};

/**
 * @category AST Type
 */
export const LabeledStatement: NodePredicate<ts.LabeledStatement> = {
    is(node): node is ts.LabeledStatement {
        return ts.isLabeledStatement(node);
    },
};

/**
 * @category AST Type
 */
export const ThrowStatement: NodePredicate<ts.ThrowStatement> = {
    is(node): node is ts.ThrowStatement {
        return ts.isThrowStatement(node);
    },
};

/**
 * @category AST Type
 */
export const TryStatement: NodePredicate<ts.TryStatement> = {
    is(node): node is ts.TryStatement {
        return ts.isTryStatement(node);
    },
};
